<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script type="text/javascript">

    function addSubProjectDivN(tr,showDiv, url) {
        $(tr).each(function(i,e){
            $(this).parent().find("tr").removeClass("table-selected");
            $(this).addClass("table-selected");
//            }
        })
        loadDiv(showDiv, url);
    }



  function addTreat(visitId,patientId,prescApplyId){
    var trList = $("#itemTableList").find("tbody tr");
    var list = "";
    var text = "";
    for(var i=0;i<trList.length;i++){
      var tdArr = trList.eq(i).find("td");
      var orderClass = tdArr.eq(0).find('input').val();//类别
      var repeatIncaditor = tdArr.eq(1).find('input').val();//长期/临时
      var billingAttr = tdArr.eq(2).find('input').val();//计价属性
      var orderText = tdArr.eq(3).text()//医嘱名称
      var performFreq = tdArr.eq(4).find('input').val();//频次
      var administration = tdArr.eq(5).find('input').val();//途径
      var singleDose = tdArr.eq(6).find('input').val();//单次用量
      var singleDoseUnit = tdArr.eq(7).text();//最小包装单位
      var packageSpec = tdArr.eq(8).text();//包装规格
      var nursePerformTime = tdArr.eq(10).find('input').val();//护士执行时间
      var doctInstruction = tdArr.eq(11).text();//医生说明
//      var price = tdArr.eq(9).text();//单价
//      var doctInstruction = tdArr.eq(10).text();//医生说明
      var id = tdArr.eq(12).find("input").eq(0).val();//id
      var parent = tdArr.eq(12).find("input").eq(1).val();//父级id
      var clinicItemId = tdArr.eq(12).find("input").eq(2).val();//项目id
      var performedBy = tdArr.eq(12).find("input").eq(3).val();//开单科室
      var minUnits = tdArr.eq(12).find("input").eq(4).val();//最小包装单位
      var firmName = tdArr.eq(12).find("input").eq(5).val();//厂家name
      var firmId = tdArr.eq(12).find("input").eq(6).val();//厂家id
      var isDrug = tdArr.eq(12).find("input").eq(7).val();//药品／非药品／手动
      var doseUnitsMetering = tdArr.eq(12).find("input").eq(8).val();//最小单位为计量
      var minSpec = tdArr.eq(12).find("input").eq(9).val();//药最小规格
      var drugUnits = tdArr.eq(12).find("input").eq(10).val();//包装单位
      text+="<tr><td><input type='hidden' name='list["+i+"].orderClass'"+" value='"+orderClass+"'/>" +
      "<input type='hidden' name='list["+i+"].repeatIncaditor'"+" value='"+repeatIncaditor+"'/>" +
      "<input type='hidden' name='list["+i+"].billingAttr'"+" value='"+billingAttr+"'/>" +
      "<input type='hidden' name='list["+i+"].orderText'"+" value='"+orderText+"'/>" +
      "<input type='hidden' name='list["+i+"].performFreq'"+" value='"+performFreq+"'/>" +
      "<input type='hidden' name='list["+i+"].administration'"+" value='"+administration+"'/>" +
      "<input type='hidden' name='list["+i+"].doseUnits'"+" value='"+singleDoseUnit+"'/>" +
      "<input type='hidden' name='list["+i+"].drugSpec'"+" value='"+packageSpec+"'/>" + // 包装规格
      "<input type='hidden' name='list["+i+"].nursePerformTime'"+" value='"+nursePerformTime+"'/>" +
      "<input type='hidden' name='list["+i+"].doctInstruction'"+" value='"+doctInstruction+"'/>" +
      "<input type='hidden' name='list["+i+"].tempalteId'"+" value='"+id+"'/>" +
      "<input type='hidden' name='list["+i+"].parent.id'"+" value='"+parent+"'/>" +
      "<input type='hidden' name='list["+i+"].clinicItemId'"+" value='"+clinicItemId+"'/>" +
      "<input type='hidden' name='list["+i+"].performedBy'"+" value='"+performedBy+"'/>" +
      "<input type='hidden' name='list["+i+"].minUnits'"+" value='"+minUnits+"'/>" +
      "<input type='hidden' name='list["+i+"].firmName'"+" value='"+firmName+"'/>" +
      "<input type='hidden' name='list["+i+"].firmId'"+" value='"+firmId+"'/>" +
      "<input type='hidden' name='list["+i+"].singleDoseUnit'"+" value='"+doseUnitsMetering+"'/>" +
      "<input type='hidden' name='list["+i+"].minSpec'"+" value='"+minSpec+"'/>" +
      "<input type='hidden' name='list["+i+"].packageUnits'"+" value='"+drugUnits+"'/>" +
      "<input type='hidden' name='list["+i+"].singleDose'"+" value='"+singleDose+"'/>" +
      "</td></tr>";
    }
    list = "<table>"+text+"</table>";
    $("#addForm").html(list);
    parentDivLoad('rigthDoctorCenterDiv','addForm','${ctx}/orders/orders/index?patientId='+patientId+'&visitId='+ visitId, '${ctx}/orders/orders/saveTreatTemplate?prescApplyId='+prescApplyId+'&visitId=' + visitId + '&patientId=' + patientId);

  }




</script>
<form id="addForm">

</form>
<div class="panel-body">
          <%--<form:form id="searchForm" modelAttribute="doctorTempla"  onsubmit="return loadDivForm('mainCenterDiv','searchFormDict','${ctx}/template/doctorTempla/index');" method="post" class="form-inline">--%>
          <%--<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>--%>
          <%--<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>--%>
          <%--<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>--%>
          <%--</form:form>--%>
            <input class="btn btn-new" onclick="addTreat('${visitId}','${patientId}','${prescApplyId}')" type="button" value="插入">

     <table id="contentTable" class="table table-bordered mg-t datatable">
        <thead>
        <tr>
          <th style="display:none">id</th>
          <th>序号</th>
          <th>主题</th>
          <th>子标题</th>
          <th>范围</th>
          <th>科室</th>
          <th>类型</th>
          <th>长期/临时</th>
          <th>项目类别</th>
          <th>诊断描述</th>
          <th>建议</th>
          <th>创建人</th>
          <%--<th>操作</th>--%>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${pageApply}" var="doctorTempla" varStatus="count">
          <tr onclick="addSubProjectDivN(this,'treatProjectItem','${ctx}/doctor/outpTreatRec/indexTreatSub?type=1&id=${doctorTempla.id}')">
            <td style="display:none">${doctorTempla.id}</td>
            <td> ${count.index+1}</td>
            <td> ${doctorTempla.title}</td>
            <td> ${doctorTempla.subTitle}</td>
            <td> ${fns:getDictLabels(doctorTempla.flag, 'FLAG', '')}</td>
            <td> ${fns:getDeptName(doctorTempla.deptCode,'')}</td>
            <td> ${fns:getDictLabels(doctorTempla.projectType,'PROJECT_TYPE','')}</td>
            <td> <c:if test="${doctorTempla.repeatIndiractor eq 0}">
                    临时
                  </c:if>
                <c:if test="${doctorTempla.repeatIndiractor eq 1}">
                    长期
                </c:if>
            </td>
            <td> <c:if test="${doctorTempla.itemClass eq 0}">
                    药品
                 </c:if>
                 <c:if test="${doctorTempla.itemClass eq 1}">
                   非药品
                 </c:if>
                 <c:if test="${doctorTempla.itemClass eq 2}">
                   手动录入
                 </c:if>
            </td>
            <td> ${doctorTempla.advice}</td>
            <td> ${doctorTempla.diagnosis}</td>
            <td> ${doctorTempla.name}</td>
            <%--<td>--%>
              <%--<a href="#" onclick="addClinic('rigthCenterDiv','${ctx}/template/doctorTempla/formTreat?type=1&id=${doctorTempla.id}')"  class="btn btn-success btn-xs">修改</a>--%>
              <%--<a href="#"  class="applyBt btn btn-danger btn-xs" onclick="confirmExtend('确认要删除该吗？',function(){delLoad('mainCenterDiv','${ctx}/template/doctorTempla/delete?id=${doctorTempla.id}','${ctx}/template/doctorTempla/indexTreat?type=1')})">删除</a>--%>
            <%--</td>--%>
          </tr>
        </c:forEach>
      </table>
</div>

